/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package structures.table.symboltable;

/**
 *
 * @author Vlad
 */
public class TerminalItemInfo extends ItemInfo implements Cloneable{

    private TerminalType type;

    public TerminalItemInfo(String name, TerminalType type) {
        super(name);
        this.type = type;
    }

    public TerminalType getType() {
        return type;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final TerminalItemInfo other = (TerminalItemInfo) obj;
        if (this.type != other.type) {
            return false;
        }
        
        if (type == TerminalType.KEY_WORD || type == TerminalType.PUNCTUATOR) {
        	if (!name.equals(other.name)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 41 * hash + (this.type != null ? this.type.hashCode() : 0) + super.hashCode();
        return hash;
    }

    @Override
    public String toString() {
        return "{" + super.toString() + ", " + type + "}";
    }

	@Override
	public Object clone() {
		return new TerminalItemInfo(name, type);
	}
    
}
